package net.sk.rm;

import java.io.*;

import javax.imageio.ImageIO;

import org.apache.mina.core.buffer.IoBuffer;

import net.sk.pt.State;

public class rmData implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	char ctype;
	State s;
	byte[] f;
	
	
	public char getCtype() {
		return ctype;
	}
	public void setCtype(char ctype) {
		this.ctype = ctype;
	}
	public State getS() {
		return s;
	}
	public void setS(State s) {
		this.s = s;
	}
	public byte[] getF() {
		return f;
	}
	public void setF(byte[] f) {
		this.f = f;
	}
	public rmData( char ctype, State s, byte[] f) {
		super();
		this.ctype = ctype;
		this.s = s;
		this.f = f;
	}
	   public static byte[] intToByteArray(long value){
		    byte[] b = new byte[4];
		     for (int i = 0; i < 4; i++) {
		            int offset = (b.length - 1 - i) * 8;
		             b[i] = (byte) ((value >>> offset) & 0xFF);
		      }
		      return b;
		   }
		  public static final int byteArrayToInt(byte b0,byte b1,byte b2,byte b3) {
	       return (b0 << 24)
	               + ((b1 & 0xFF) << 16)
	               + ((b2 & 0xFF) << 8)
	               + (b3 & 0xFF);
		  }
		  public static void putbyte(byte[]target,int pos,byte[]source){
			  for(int i=0; i<source.length; i++){
				  target[pos+i]=source[i];
			  }
		  }
	public byte[] encode() throws IOException{
        ByteArrayOutputStream bout = new ByteArrayOutputStream();   
        ObjectOutputStream out = new ObjectOutputStream(bout);   
        out.writeObject(this);   
        out.flush();   
        byte[] b_out = bout.toByteArray();
        bout.close();   
        out.close();   
        return b_out;  		
	}
}
